/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('es-serverless', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model DataStreamMapping {
  caseSensitive?: boolean(name='caseSensitive'),
  docValues?: boolean(name='docValues'),
  index?: boolean(name='index'),
  key?: string(name='key'),
  properties?: [
    DataStreamMapping
  ](name='properties'),
  tokenizeOnChars?: [ string ](name='tokenizeOnChars'),
  type?: string(name='type'),
}

model CreateAppRequest {
  appName?: string(name='appName', description='应用名', example='es-severless-test-app'),
  chargeType?: string(name='chargeType', example='POSTPAY'),
  description?: string(name='description', description='应用备注'),
}

model CreateAppResponseBody = {
  requestId?: string(name='requestId', example='2C5DAA30-****-5181-9B87-9D6181016197'),
}

model CreateAppResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateAppResponseBody(name='body'),
}

async function createAppWithOptions(request: CreateAppRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateAppResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.appName)) {
    body['appName'] = request.appName;
  }
  if (!Util.isUnset(request.chargeType)) {
    body['chargeType'] = request.chargeType;
  }
  if (!Util.isUnset(request.description)) {
    body['description'] = request.description;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateApp',
    version = '2022-08-22',
    protocol = 'HTTPS',
    pathname = `/openapi/xops/instances`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createApp(request: CreateAppRequest): CreateAppResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createAppWithOptions(request, headers, runtime);
}

model CreateDataStreamRequest {
  dataStreamName?: string(name='dataStreamName', description='代表资源名称的资源属性字段'),
  deletePhase?: string(name='deletePhase', description='删除时间'),
  dynamic?: string(name='dynamic'),
  regionId?: string(name='regionId'),
  template?: {
    mappings?: [
      DataStreamMapping
    ](name='mappings', description='索引字段设置'),
  }(name='template', description='数据流模板'),
  timeStampKey?: string(name='timeStampKey'),
  type?: string(name='type', description='数据流类型'),
}

model CreateDataStreamResponseBody = {
  requestId?: string(name='requestId'),
}

model CreateDataStreamResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateDataStreamResponseBody(name='body'),
}

async function createDataStreamWithOptions(appName: string, request: CreateDataStreamRequest, headers: map[string]string, runtime: Util.RuntimeOptions): CreateDataStreamResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.dataStreamName)) {
    body['dataStreamName'] = request.dataStreamName;
  }
  if (!Util.isUnset(request.deletePhase)) {
    body['deletePhase'] = request.deletePhase;
  }
  if (!Util.isUnset(request.dynamic)) {
    body['dynamic'] = request.dynamic;
  }
  if (!Util.isUnset(request.regionId)) {
    body['regionId'] = request.regionId;
  }
  if (!Util.isUnset(request.template)) {
    body['template'] = request.template;
  }
  if (!Util.isUnset(request.timeStampKey)) {
    body['timeStampKey'] = request.timeStampKey;
  }
  if (!Util.isUnset(request.type)) {
    body['type'] = request.type;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateDataStream',
    version = '2022-08-22',
    protocol = 'HTTPS',
    pathname = `/openapi/xops/instances/${OpenApiUtil.getEncodeParam(appName)}/data-streams`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createDataStream(appName: string, request: CreateDataStreamRequest): CreateDataStreamResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return createDataStreamWithOptions(appName, request, headers, runtime);
}

model DeleteAccessTokenResponseBody = {
  requestId?: string(name='requestId'),
}

model DeleteAccessTokenResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteAccessTokenResponseBody(name='body'),
}

async function deleteAccessTokenWithOptions(tokenId: string, headers: map[string]string, runtime: Util.RuntimeOptions): DeleteAccessTokenResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'DeleteAccessToken',
    version = '2022-08-22',
    protocol = 'HTTPS',
    pathname = `/openapi/xops/tokens/${OpenApiUtil.getEncodeParam(tokenId)}`,
    method = 'DELETE',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function deleteAccessToken(tokenId: string): DeleteAccessTokenResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteAccessTokenWithOptions(tokenId, headers, runtime);
}

model DeleteAppResponseBody = {
  requestId?: string(name='requestId'),
  result?: {
    instanceId?: string(name='instanceId'),
  }(name='result'),
}

model DeleteAppResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteAppResponseBody(name='body'),
}

async function deleteAppWithOptions(appName: string, headers: map[string]string, runtime: Util.RuntimeOptions): DeleteAppResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'DeleteApp',
    version = '2022-08-22',
    protocol = 'HTTPS',
    pathname = `/openapi/xops/instances/${OpenApiUtil.getEncodeParam(appName)}`,
    method = 'DELETE',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function deleteApp(appName: string): DeleteAppResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteAppWithOptions(appName, headers, runtime);
}

model DeleteDataStreamResponseBody = {
  requestId?: string(name='requestId', example='2C5DAA30-****-5181-9B87-9D6181016197'),
  result?: boolean(name='result', example='true'),
}

model DeleteDataStreamResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteDataStreamResponseBody(name='body'),
}

async function deleteDataStreamWithOptions(appName: string, dataStreamName: string, headers: map[string]string, runtime: Util.RuntimeOptions): DeleteDataStreamResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'DeleteDataStream',
    version = '2022-08-22',
    protocol = 'HTTPS',
    pathname = `/openapi/xops/instances/${OpenApiUtil.getEncodeParam(appName)}/data-streams/${OpenApiUtil.getEncodeParam(dataStreamName)}`,
    method = 'DELETE',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function deleteDataStream(appName: string, dataStreamName: string): DeleteDataStreamResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return deleteDataStreamWithOptions(appName, dataStreamName, headers, runtime);
}

model DescibeRegionsResponseBody = {
  requestId?: string(name='requestId'),
  result?: [ 
    {
      endpoint?: string(name='endpoint'),
      localName?: string(name='localName'),
      regionId?: string(name='regionId'),
    }
  ](name='result'),
}

model DescibeRegionsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescibeRegionsResponseBody(name='body'),
}

async function descibeRegionsWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): DescibeRegionsResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'DescibeRegions',
    version = '2022-08-22',
    protocol = 'HTTPS',
    pathname = `/openapi/xops/regions`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function descibeRegions(): DescibeRegionsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return descibeRegionsWithOptions(headers, runtime);
}

model DisableAccessTokenResponseBody = {
  requestId?: string(name='requestId'),
}

model DisableAccessTokenResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DisableAccessTokenResponseBody(name='body'),
}

async function disableAccessTokenWithOptions(tokenId: string, headers: map[string]string, runtime: Util.RuntimeOptions): DisableAccessTokenResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'DisableAccessToken',
    version = '2022-08-22',
    protocol = 'HTTPS',
    pathname = `/openapi/xops/tokens/${OpenApiUtil.getEncodeParam(tokenId)}/actions/disable`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function disableAccessToken(tokenId: string): DisableAccessTokenResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return disableAccessTokenWithOptions(tokenId, headers, runtime);
}

model EnableAccessTokenResponseBody = {
  requestId?: string(name='requestId'),
}

model EnableAccessTokenResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: EnableAccessTokenResponseBody(name='body'),
}

async function enableAccessTokenWithOptions(tokenId: string, headers: map[string]string, runtime: Util.RuntimeOptions): EnableAccessTokenResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'EnableAccessToken',
    version = '2022-08-22',
    protocol = 'HTTPS',
    pathname = `/openapi/xops/tokens/${OpenApiUtil.getEncodeParam(tokenId)}/actions/enable`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function enableAccessToken(tokenId: string): EnableAccessTokenResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return enableAccessTokenWithOptions(tokenId, headers, runtime);
}

model GenerateAcccessTokenResponseBody = {
  requestId?: string(name='requestId'),
}

model GenerateAcccessTokenResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GenerateAcccessTokenResponseBody(name='body'),
}

async function generateAcccessTokenWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): GenerateAcccessTokenResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GenerateAcccessToken',
    version = '2022-08-22',
    protocol = 'HTTPS',
    pathname = `/openapi/xops/tokens`,
    method = 'POST',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function generateAcccessToken(): GenerateAcccessTokenResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return generateAcccessTokenWithOptions(headers, runtime);
}

model GetAppResponseBody = {
  requestId?: string(name='requestId', example='2C5DAA30-****-5181-9B87-9D6181016197'),
  result?: {
    appName?: string(name='appName', description='代表资源名称的资源属性字段', example='es-severless-test-app'),
    createTime?: string(name='createTime', description='代表创建时间的资源属性字段', example='2022-12-27T07:09:11.000Z'),
    description?: string(name='description', description='应用备注'),
    flowQuota?: string(name='flowQuota', description='流量限流额', example='***'),
    ownerId?: string(name='ownerId', description='OwnerID账号ID', example='*******7595'),
    regionId?: string(name='regionId', description='代表region的资源属性字段', example='cn-hangzhou'),
    status?: string(name='status', description='代表资源状态的资源属性字段', example='ACTIVE'),
    storageQuota?: string(name='storageQuota', description='存储限流额', example='***'),
  }(name='result'),
}

model GetAppResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetAppResponseBody(name='body'),
}

async function getAppWithOptions(appName: string, headers: map[string]string, runtime: Util.RuntimeOptions): GetAppResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetApp',
    version = '2022-08-22',
    protocol = 'HTTPS',
    pathname = `/openapi/xops/instances/${OpenApiUtil.getEncodeParam(appName)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getApp(appName: string): GetAppResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getAppWithOptions(appName, headers, runtime);
}

model GetDataStreamResponseBody = {
  requestId?: string(name='requestId'),
  result?: {
    appName?: string(name='appName', description='关联的应用AppId'),
    createTime?: string(name='createTime', description='代表创建时间的资源属性字段'),
    dataStreamId?: string(name='dataStreamId', description='代表资源一级ID的资源属性字段'),
    dataStreamName?: string(name='dataStreamName', description='代表资源名称的资源属性字段'),
    deletePhase?: string(name='deletePhase', description='删除时间'),
    regionId?: string(name='regionId', description='代表region的资源属性字段'),
    template?: {
      mappings?: [
        DataStreamMapping
      ](name='mappings', description='索引字段设置'),
    }(name='template', description='数据流模板'),
    timeStampKey?: string(name='timeStampKey'),
    type?: string(name='type', description='数据流类型'),
  }(name='result'),
}

model GetDataStreamResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetDataStreamResponseBody(name='body'),
}

async function getDataStreamWithOptions(appName: string, dataStreamName: string, headers: map[string]string, runtime: Util.RuntimeOptions): GetDataStreamResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetDataStream',
    version = '2022-08-22',
    protocol = 'HTTPS',
    pathname = `/openapi/xops/instances/${OpenApiUtil.getEncodeParam(appName)}/data-streams/${OpenApiUtil.getEncodeParam(dataStreamName)}`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getDataStream(appName: string, dataStreamName: string): GetDataStreamResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getDataStreamWithOptions(appName, dataStreamName, headers, runtime);
}

model GetRegionInfoResponseBody = {
  requestId?: string(name='requestId', example='2C5DAA30-****-5181-9B87-9D6181016197'),
}

model GetRegionInfoResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetRegionInfoResponseBody(name='body'),
}

async function getRegionInfoWithOptions(headers: map[string]string, runtime: Util.RuntimeOptions): GetRegionInfoResponse {
  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
  };
  var params = new OpenApi.Params{
    action = 'GetRegionInfo',
    version = '2022-08-22',
    protocol = 'HTTPS',
    pathname = `/openapi/xops/regions/info`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getRegionInfo(): GetRegionInfoResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return getRegionInfoWithOptions(headers, runtime);
}

model ListAccessTokensRequest {
  tokenId?: string(name='tokenId'),
}

model ListAccessTokensResponseBody = {
  requestId?: string(name='requestId'),
}

model ListAccessTokensResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListAccessTokensResponseBody(name='body'),
}

async function listAccessTokensWithOptions(request: ListAccessTokensRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListAccessTokensResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.tokenId)) {
    query['tokenId'] = request.tokenId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListAccessTokens',
    version = '2022-08-22',
    protocol = 'HTTPS',
    pathname = `/openapi/xops/tokens`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listAccessTokens(request: ListAccessTokensRequest): ListAccessTokensResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listAccessTokensWithOptions(request, headers, runtime);
}

model ListAppsRequest {
  appName?: string(name='appName', example='es-severless-test-app'),
  description?: string(name='description', example='metrics-logs-online'),
  pageNumber?: int32(name='pageNumber', example='2'),
  pageSize?: int32(name='pageSize', example='20'),
}

model ListAppsResponseBody = {
  requestId?: string(name='requestId', example='2C5DAA30-****-5181-9B87-9D6181016197'),
  result?: [ 
    {
      appName?: string(name='appName', description='代表资源名称的资源属性字段', example='es-severless-test-app'),
      createTime?: string(name='createTime', description='代表创建时间的资源属性字段', example='2022-12-27T07:09:11.000Z'),
      description?: string(name='description', description='应用备注'),
      flowQuota?: string(name='flowQuota', description='流量限流额', example='***'),
      ownerId?: string(name='ownerId', description='OwnerID账号ID', example='*********7595'),
      regionId?: string(name='regionId', description='代表region的资源属性字段', example='cn-hangzhou'),
      status?: string(name='status', description='代表资源状态的资源属性字段', example='ACTIVE'),
      storageQuota?: string(name='storageQuota', description='存储限流额', example='***'),
    }
  ](name='result'),
  totalCount?: int32(name='totalCount', example='68'),
}

model ListAppsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListAppsResponseBody(name='body'),
}

async function listAppsWithOptions(request: ListAppsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListAppsResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.appName)) {
    query['appName'] = request.appName;
  }
  if (!Util.isUnset(request.description)) {
    query['description'] = request.description;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['pageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['pageSize'] = request.pageSize;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListApps',
    version = '2022-08-22',
    protocol = 'HTTPS',
    pathname = `/openapi/xops/instances`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listApps(request: ListAppsRequest): ListAppsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listAppsWithOptions(request, headers, runtime);
}

model ListDataStreamsRequest {
  dataStreamName?: string(name='dataStreamName'),
  pageNumber?: int32(name='pageNumber'),
  pageSize?: int32(name='pageSize'),
  regionId?: string(name='regionId'),
}

model ListDataStreamsResponseBody = {
  requestId?: string(name='requestId'),
  result?: [ 
    {
      appName?: string(name='appName', description='关联的应用AppId'),
      createTime?: string(name='createTime', description='代表创建时间的资源属性字段'),
      dataStreamId?: string(name='dataStreamId', description='代表资源一级ID的资源属性字段'),
      dataStreamName?: string(name='dataStreamName', description='代表资源名称的资源属性字段'),
      deletePhase?: string(name='deletePhase', description='删除时间'),
      regionId?: string(name='regionId', description='代表region的资源属性字段'),
      template?: {
        mappings?: [
          DataStreamMapping
        ](name='mappings', description='索引字段设置'),
      }(name='template', description='数据流模板'),
      timeStampKey?: string(name='timeStampKey'),
      type?: string(name='type', description='数据流类型'),
    }
  ](name='result'),
  totalCount?: int32(name='totalCount'),
}

model ListDataStreamsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListDataStreamsResponseBody(name='body'),
}

async function listDataStreamsWithOptions(appName: string, request: ListDataStreamsRequest, headers: map[string]string, runtime: Util.RuntimeOptions): ListDataStreamsResponse {
  Util.validateModel(request);
  var query : map[string]any = {};
  if (!Util.isUnset(request.dataStreamName)) {
    query['dataStreamName'] = request.dataStreamName;
  }
  if (!Util.isUnset(request.pageNumber)) {
    query['pageNumber'] = request.pageNumber;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['pageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.regionId)) {
    query['regionId'] = request.regionId;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListDataStreams',
    version = '2022-08-22',
    protocol = 'HTTPS',
    pathname = `/openapi/xops/instances/${OpenApiUtil.getEncodeParam(appName)}/data-streams`,
    method = 'GET',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listDataStreams(appName: string, request: ListDataStreamsRequest): ListDataStreamsResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return listDataStreamsWithOptions(appName, request, headers, runtime);
}

model UpdateAppRequest {
  description?: string(name='description', description='应用备注'),
}

model UpdateAppResponseBody = {
  requestId?: string(name='requestId'),
}

model UpdateAppResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: UpdateAppResponseBody(name='body'),
}

async function updateAppWithOptions(appName: string, request: UpdateAppRequest, headers: map[string]string, runtime: Util.RuntimeOptions): UpdateAppResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.description)) {
    body['description'] = request.description;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'UpdateApp',
    version = '2022-08-22',
    protocol = 'HTTPS',
    pathname = `/openapi/xops/instances/${OpenApiUtil.getEncodeParam(appName)}`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function updateApp(appName: string, request: UpdateAppRequest): UpdateAppResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return updateAppWithOptions(appName, request, headers, runtime);
}

model UpdateDataStreamRequest {
  deletePhase?: string(name='deletePhase', description='删除时间', example='150d'),
  dynamic?: string(name='dynamic', example='false'),
  template?: {
    mappings?: [
      DataStreamMapping
    ](name='mappings'),
  }(name='template'),
  timeStampKey?: string(name='timeStampKey', example='@timestamp'),
}

model UpdateDataStreamResponseBody = {
  requestId?: string(name='requestId', example='2C5DAA30-****-5181-9B87-9D6181016197'),
  result?: {
    appName?: string(name='appName', example='es-severless-test-app'),
  }(name='result'),
}

model UpdateDataStreamResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: UpdateDataStreamResponseBody(name='body'),
}

async function updateDataStreamWithOptions(dataStreamName: string, appName: string, request: UpdateDataStreamRequest, headers: map[string]string, runtime: Util.RuntimeOptions): UpdateDataStreamResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.deletePhase)) {
    body['deletePhase'] = request.deletePhase;
  }
  if (!Util.isUnset(request.dynamic)) {
    body['dynamic'] = request.dynamic;
  }
  if (!Util.isUnset(request.template)) {
    body['template'] = request.template;
  }
  if (!Util.isUnset(request.timeStampKey)) {
    body['timeStampKey'] = request.timeStampKey;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'UpdateDataStream',
    version = '2022-08-22',
    protocol = 'HTTPS',
    pathname = `/openapi/xops/instances/${OpenApiUtil.getEncodeParam(appName)}/data-streams/${OpenApiUtil.getEncodeParam(dataStreamName)}`,
    method = 'PUT',
    authType = 'AK',
    style = 'ROA',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function updateDataStream(dataStreamName: string, appName: string, request: UpdateDataStreamRequest): UpdateDataStreamResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return updateDataStreamWithOptions(dataStreamName, appName, request, headers, runtime);
}

